package com.semidata.rtd.core.job;

import com.semidata.rtd.core.executor.TaskExecutor;

public class Job1 extends AbstractJob<TestContext> {

    private SequenceTaskScheduler scheduler;
    private TestContext context;
    private boolean isDone = false;

    public Job1(TaskExecutor executor) {
        super(null);
        this.scheduler = new SequenceTaskScheduler();
        this.context = new TestContext();
      
        scheduler.addTask(new Task1(this, executor));
        scheduler.addTask(new Task2(this, executor));
        scheduler.addTask(new Task3(this, executor));
        scheduler.addTask(new Task4(this, executor));
        scheduler.setJobCompleteHandler(new JobCompleteHandler() {

            @Override
            public void handle(Throwable cause) {
                if (cause != null)
                    cause.printStackTrace();
                System.out.println("job is done");
                isDone = true;
            }
            
        });
    }
    
    @Override
    public TaskScheduler getTaskScheduler() {
        return scheduler;
    }
    
    @Override
    public TestContext getJobContext() {
        return context;
    }
    
    public boolean isDone() {
        return isDone;
    }

    
}
